package com.atguigu.yygh.hosp.controller.user;

import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/3/24 0:26
 */
@Api(tags = "用户-排班管理")
@RestController
@RequestMapping("user/hosp")
public class ScheduleUserController {
    @Autowired
    private ScheduleService scheduleService;

    @ApiOperation(value = "获取可预约排班数据")
    @GetMapping("auth/getBookingScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public R getBookingSchedule(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit, @PathVariable("hoscode") String hoscode, @PathVariable("depcode") String depcode){
        Map<String, Object> map = scheduleService.getBookingSchedule(page, limit, hoscode, depcode);

        return R.ok().data(map);
    }
    @ApiOperation(value="获取排班详情")
    @GetMapping("/auth/findScheduleList/{hoscode}/{depcode}/{workDate}")
    public R findScheduleList(@PathVariable("hoscode") String hoscode, @PathVariable("depcode") String depcode, @PathVariable("workDate") String workDate){
        List<Schedule> scheduleList = scheduleService.getScheduleInfo(hoscode, depcode, workDate);
        return R.ok().data("scheduleList", scheduleList);
    }

    @GetMapping("/auth/getSchedule/{scheduleId}")
    public R getSchedule(@PathVariable("scheduleId") String scheduleId){
        Schedule schedule=scheduleService.getSchedule(scheduleId);
        return R.ok().data("schedule", schedule);
    }

}
